# 元素首字母排序
# 永久排序
cars = ["bmw", "audi", "toyota", "subaru"]
# ['bmw', 'audi', 'toyota', 'subaru']
print(cars)

# a-z
cars.sort()
# ['audi', 'bmw', 'subaru', 'toyota']
print(cars)

# z-a，参数
cars.sort(reverse=True)
print(cars)
print("\r")

# 临时排序
cars = ["bmw", "audi", "toyota", "subaru"]
print("原始列表顺序:")
print(cars)

print("\n排序列表顺序:")
print(sorted(cars))

print("\n原始列表顺序:")
print(cars)

# 列表反向排序
cars = ["bmw", "audi", "toyota", "subaru"]
print("\n")
# ['bmw', 'audi', 'toyota', 'subaru']
print(cars)

cars.reverse()
# ['subaru', 'toyota', 'audi', 'bmw']
print(cars)

# 列表长度
cars = ["bmw", "audi", "toyota", "subaru"]
length = len(cars)
print("\n列表长度:")
print(length)
